package com.www.conversionspring.formatters;

import org.springframework.format.AnnotationFormatterFactory;
import org.springframework.format.Formatter;
import org.springframework.format.Parser;
import org.springframework.format.Printer;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.number.CurrencyStyleFormatter;
import org.springframework.format.number.NumberStyleFormatter;
import org.springframework.format.number.PercentStyleFormatter;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.HashSet;
import java.util.Set;

import static java.util.Arrays.asList;

/**
 * <p>
 * </p>
 *
 * @author Zed.Yun
 * @Title: TranslaterFormatterFactory
 * @ProjectName conversion-spring
 * @date 2019/3/18 17:51
 */
public class TranslaterFormatterFactory  implements AnnotationFormatterFactory<TranslaterFormat> {
    @Override
    public Set<Class<?>> getFieldTypes() {
        return new HashSet<Class<?>>(asList(new Class<?>[] {
                String.class }));
    }

    @Override
    public Printer<?> getPrinter(TranslaterFormat annotation, Class<?> fieldType) {
        return configureFormatterFrom(annotation, fieldType);
    }

    @Override
    public Parser<?> getParser(TranslaterFormat annotation, Class<?> fieldType) {
        return configureFormatterFrom(annotation, fieldType);
    }

    private Formatter<String> configureFormatterFrom(TranslaterFormat annotation, Class<?> fieldType) {
            return new TranslaterFormatter();
    }
}
